package com.example.demo.repository;


import com.example.demo.entity.User;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

import java.util.List;


//public interface UserRepository extends JpaRepository<User, Long> {

@Mapper
public interface UserRepository {
    @Select("select *from user2 where id=#{id}")
    User findUserById(long id);

    @Select("SELECT * FROM user2 WHERE id = #{id}")
    User queryById(@Param("id") int id);

    //@Select("SELECT * FROM user limit 1000")
    @Select("SELECT * FROM user2")
    List<User> queryAll();

    @Insert({"INSERT INTO user2(name,age) VALUES(#{name},#{age})"})
    User save(User user);

    @Delete("DELETE FROM user WHERE id = #{id}")
    int deleteById(long id);

    @Update("UPDATE user SET name=#{name},age=#{age} WHERE id = #{id}")
    int updateById(User user);
    //
//    @Select("SELECT * FROM user limit 1000")
    @Select("SELECT * FROM user ")
    Page<User> getUserList();

}

